<div id="content">
<?php
/* Move this to a class.search.php eventually so it can be extended */
$site->setSearchTerms($_GET['q']);
$page_number=$_GET['page'];
$site->setSkipNum(0);
$results=$site->search();
if($results['num_results']<=0) {
	echo('<h1 style="color:red;padding-top:1em;">Sorry but no results could be found for "'.$_GET['q'].'"</h1>');	
} else {
	$s=($results['num_results']>1) ? 's' : '';
	echo('<h1 style="padding-top:1em;">Search Results - '.$results['num_results'].' result'.$s.' found for "'.$_GET['q'].'"</h1>');
echo('<ol>');
foreach($results['results'] as $result) {
	
	$excerpt = preg_replace('/'.$_GET['q'].'/i','<span class="highlight">$0</span>',strip_tags($result['excerpt']));
	
	$heading=(empty($result['heading'])) ? $result['text'] : $result['heading'];
	echo('<li class="search-result">');
	echo('<h2 style="margin-bottom:1em;">'.$heading.'</h2>');
	echo('<strong><a href="'.$site->settings['url'].$result['url'].'" class="result">'.$site->settings['url'].$result['url'].'</a></strong>');	
	echo('<p>'.$excerpt.' <a href="'.$site->settings['url'].$result['url'].'" class="result">more</a></p>');// this has to be split on insert
	echo('<div class="clearfix"></div>');
	echo('</li>');
}
echo('</ol>');
}
		$page_number=($_GET['page']<=0) ? 1 : $_GET['page'];
		$skip = intval((10 * ($page_number - 1)));
		$num_pages=ceil(($row['num_results']/10));
			$max_pages=4;
$pagination=$site->pagination($page_number,$num_pages,$max_pages,"?q=".strtolower($_GET['q'])."&page=$page_number");
			if(!empty($pagination)) {
				echo('<div style="text-align:right;padding-top:1em;padding-bottom:1em;">'.$pagination.'</div>');
			}
?>
</div>